
package com.example.tests;

import static com.example.tests.GroupDataGenerator.loadGroupsFromCsvFile;
import static com.example.tests.GroupDataGenerator.loadGroupsFromXmlFile;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.example.utils.SortedListOf;
// import of a class in a current name space
// import of a separate method from Assert class

public class GroupCreationTests extends TestBase {
	

  @DataProvider
  public Iterator<Object[]> groupsFromFile() throws IOException {
		return wrapGroupsForDataProvider(loadGroupsFromXmlFile(new File("groups.xml"))).iterator();
	}
  

@Test(dataProvider = "groupsFromFile")
  public void testGroupCreationWithValidData(GroupData group) throws Exception {
    
	SortedListOf<GroupData> oldList = app.getGroupHelper().getGroups();
    
    app.getGroupHelper().createGroup(group);
    
    SortedListOf<GroupData> newList = app.getGroupHelper().getGroupsFromUI();
    
    assertThat(newList, equalTo(oldList.withAdded(group)));
    //oldList.add(group);
    //Collections.sort(oldList);
    //assertEquals(newList,oldList);
  }

}
